<%@page language="java" pageEncoding="gb2312"%>
<%@page import="java.util.*"%>
<%@page import="dreamtime.dreamnews.news.*"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.sql.*"%>
<%@page import="dreamtime.dreamnews.*"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.text.SimpleDateFormat"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%      
        StringBuffer outTitle=new StringBuffer("");
		int viewType=1;
		int smallclassid=1;
		int startNum=0;
		int listNum=11;
		int titleNum=10;
		int modelNum=1;
		String viewTypeStr=request.getParameter("viewType");
        if(viewTypeStr!=null&&viewTypeStr.matches("[0-9]*[1-9][0-9]*")){
        	viewType=Integer.parseInt(viewTypeStr);
        }
        String idString=request.getParameter("smallclassid");
        if(idString!=null&&idString.matches("[0-9]*[1-9][0-9]*")){
        	smallclassid=Integer.parseInt(idString);
        }
        String startString=request.getParameter("startNum");
        if(startString!=null&&startString.matches("[0-9]*[1-9][0-9]*")){
        	startNum=Integer.parseInt(startString);
        }
        String listString=request.getParameter("listNum");
        if(listString!=null&&listString.matches("[0-9]*[1-9][0-9]*")){
        	listNum=Integer.parseInt(listString);
        }
        String titleString=request.getParameter("titleNum");
        if(titleString!=null&&titleString.matches("[0-9]*[1-9][0-9]*")){
        	titleNum=Integer.parseInt(titleString);
        }
        String modelString=request.getParameter("modelNum");
        if(modelString!=null&&modelString.matches("[0-9]*[1-9][0-9]*")){
        	modelNum=Integer.parseInt(modelString);
        }
        DBConnection accessconn=new DBConnection();
        Connection conn=null;
        PreparedStatement pstmt=null;
		ResultSet rs=null;	
	try{ 
        conn=accessconn.getConn();
        pstmt=conn.prepareStatement("select newsid,newstitle,newstime,newsInfo,newspicture,headPicture,newsContent from news where smallclassid=? order by newsid desc",ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
        HashMap     reportNewsMap=LinkNews.getNewsMap(conn,pstmt,rs,smallclassid,startNum,listNum,titleNum);
		ArrayList   reportIdList=(ArrayList)reportNewsMap.get("newsid");
		ArrayList   reportTitleList=(ArrayList)reportNewsMap.get("newstitle");
		ArrayList   reportTimeList=(ArrayList)reportNewsMap.get("newstime");
		ArrayList   reportInfoList=(ArrayList)reportNewsMap.get("newsInfoList");
		for(int i=0;i<reportIdList.size();i++){ 
			String newsId=(String)reportIdList.get(i);
			String newsTitle=(String)reportTitleList.get(i);
			String newsInfo="";
			Object newsInfoObj=reportInfoList.get(i);
			if(newsInfoObj!=null){
				newsInfo=(String)newsInfoObj;
			}
	        if(viewType==1){
	        	outTitle.append("<li>");
	        	outTitle.append("<a ");
	        	outTitle.append(" href='"+basePath+"ghtz/newsContent.jsp?newsid="+newsId+"&smallclassid="+smallclassid+"'");
	        	outTitle.append(" title='"+newsTitle+"' newsInfo='"+newsInfo+"'  target='_blank'>");
	        	outTitle.append(newsTitle);
	        	outTitle.append("</a>");
	        	outTitle.append("</li>");
	        }else if(viewType==2){ %>
	        	<div id="headline_block<%=i+1%>">
				    <div>
				        <div id="headline_title"><a href="<%=basePath%>ghtz/newsContent.jsp?newsid=<%=newsId%>&smallclassid=<%=smallclassid%>"> <%=(String)newsTitle%> </a></div>
				        <div id="headline_time"><a href="<%=basePath%>ghtz/newsContent.jsp?newsid=<%=newsId%>&smallclassid=<%=smallclassid%>"><%=(String)reportTimeList.get(i)%></a></div>
				        <div id="headline_readmore"><a href="<%=basePath%>ghtz/newsContent.jsp?newsid=<%=newsId%>&smallclassid=<%=smallclassid%>">READ MORE</a></div>
				    </div>
				</div>
	        <% }else if(viewType==3){%>
	       		<div>
					<div id="subject_comment">
						<a href="<%=basePath%>ghtz/newsContent.jsp?newsid=<%=newsId%>&smallclassid=<%=smallclassid%>"><%=(String)newsTitle%></a>
					</div>
					<div id="subject_time">
						<a href="<%=basePath%>ghtz/newsContent.jsp?newsid=<%=newsId%>&smallclassid=<%=smallclassid%>"><%=(String)reportTimeList.get(i)%></a>
					</div>
				</div>
	        <%}else if(viewType==4){%>
       			<div id="subject_comment1">
					<a href="<%=basePath%>ghtz/newsContent.jsp?newsid=<%=newsId%>&smallclassid=<%=smallclassid%>">
					<%=(String)newsTitle%><br/>
					</a>
				</div>
	        <%
			}
		}
		out.print(outTitle.toString());
  }catch(SQLException se){
  out.print(se.getMessage());
  }finally{
  accessconn.closeResultSet(rs);
  accessconn.closePreparedStatement(pstmt);
  accessconn.closeConnection(conn);
  }
%>
